package durose.system.springUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import durose.system.pojo.Dept;

import com.github.pagehelper.Page;



/**
 * 获取分页对象，重新封装
 * @author Administrator
 *
 */
@Component
public class SpringDeptFactory {

	
	
	
	public static SpringDeptFactory me(){
		 return SpringContextHolder.getBean("springDeptFactory");
	}
	//将List<Boss>格式的数据 改造成List<Map<String,Object>>类型，并在此处初始化一对多
	@SuppressWarnings("all")
	public List<Map<String,Object>> initData(Page page){
		Page pageNew = page;
		List<Dept> lists = pageNew.getResult();
		List<Map<String,Object>> mapList = new ArrayList<>();
		for(Dept dept:lists){
			Map<String,Object> map  = new HashMap<String, Object>();
			map.put("dept_id",dept.getDept_id());
map.put("dept_picture",dept.getDept_picture());
map.put("dept_name",dept.getDept_name());
map.put("dept_number",dept.getDept_number());

			mapList.add(map);
		}
		pageNew.clear();
		pageNew.addAll(mapList);
		return pageNew;
	}
	
	
}
